package Demo01;

public class RuntimeDemo01 {
    public static void main(String[] args) throws Exception{
        Runtime runtime =Runtime.getRuntime();
        String message = "www.yootk.com";
        for (int x = 0; x < 25; x++){
            message += message + x + "\n";
        }
        System.out.println("[1]垃圾产生后的内存信息：MaxMemory = " + runtime.maxMemory());
        System.out.println("[1]垃圾产生后的内存信息：TotalMemory = " + runtime.totalMemory());
        System.out.println("[1]垃圾产生后的内存信息：FreeMemory = " + runtime.freeMemory());
        runtime.gc();
        System.out.println("[2]GC调用之后的内存信息：MaxMemory = " + runtime.maxMemory());
        System.out.println("[2]GC调用之后的内存信息：TotalMemory = " + runtime.totalMemory());
        System.out.println("[2]GC调用之后的内存信息：FreeMemory = " + runtime.freeMemory());
    }
}
